<!DOCTYPE html>
<meta charset="utf-8" />
<link rel="stylesheet" href="ace_v1.3/assets/css/ui.jqgrid.css" />

<div class="search_panel">
<form action="" id="rechargeSearchForm" method="post" onsubmit="return pageSearch(this);">
	<div style="display: block;" class="widget-body ">
		<div class="widget-main">
			<div class="rowt">
				<div class="col-sm-12">
					<div>
					<div class="search_elm" style="margin-left: 0px">
							<label class="label_search">订单号:</label>
							<div class="search_input">
								<input id="prdOrdNo" type="text" name="prdOrdNo" placeholder="请输入订单号">
							</div>
						</div>
					<div class="search_elm" style="margin-left: 0px">
							<label class="label_search">商户编号:</label>
							<div class="search_input">
								<input id="custId" type="text" name="custId" placeholder="请输入商户编号">
							</div>
						</div>
						<div class="search_elm" style="margin-left: 0px">
							<label class="label_search">商户名称:</label>
							<div class="search_input">
								<input id="custName" type="text" name="custName" placeholder="请输入商户名称">
							</div>
						</div>
						
						<!-- <div class="search_elm" style="margin-left: 0px">
							<label class="label_search">合作商编号:</label>
							<div class="search_input">
								<input id="agentId" type="text" name="agentId" placeholder="请输入商户名称">
							</div>
						</div> -->
						<div class="search_elm" style="margin-left: 0px">
							<label class="label_search">银行卡号:</label>
							<div class="search_input">
								<input id="bankpayacno" type="text" name="payCardNo" placeholder="请输入银行卡号">
							</div>
						</div>
						<div class="search_elm" style="margin-left: 0px">
							<label class="label_search">合作商编号:</label>
							<div class="search_input">
								<input id="agentId" type="text" name="agentId" placeholder="请输入合作商编号">
							</div>
						</div>
						<div class="search_elm" style="margin-left: 0px">
							<label class="label_search">合作商名称:</label>
							<div class="search_input">
								<input id="agentName" type="text" name="agentName" placeholder="请输入合作商名称">
							</div>
						</div>
						
						<!-- <div class="search_elm" style="margin-left: 0px">
							<label class="label_search">开户行:</label>
							<div class="search_input">
								<input id="bankcode" type="text" name="bankcode" placeholder="请输入开户行">
							</div>
						</div> -->
						<div class="search_elm" style="margin-left: 0px">
							<label class="label_search">订单状态:</label>
							<div class="search_input">
							<select 
								rel="obj.ORDSTATUS"
								location="local" 
								 name="ordStatus" 
								 id="search_paystatus" 
								  style="width: 120px;vertical-align:middle;">
								  <option value="">---选择---<option>
						 </select>
							</div>
						</div>
						<div class="search_elm" style="margin-left: 0px">
							<label class="label_search">支付方式:</label>
							<div class="search_input">
							<select 
								rel="obj.PAYTYPE"
								location="local" 
								 name="payType" 
								 id="payType" 
								 style="width: 120px;vertical-align:middle;">
								 <option value="">---选择---<option>
						 </select>
							</div>
						</div>
						<div class="search_elm" style="margin-left: 0px;margin-right: 15px;width: 280px;">
						    <label class="label_search" for="userName">订单时间:</label>
							<div class="input-group">
								<input type="text" class="form-control date-picker"  name="prdDateStart" data-date-format="yyyy-mm-dd" placeholder="起始日期" />
								<span class="input-group-addon">
									<i class="fa fa-exchange"></i>
								</span>
								<input type="text" class="form-control date-picker"  name="prdDateEnd" data-date-format="yyyy-mm-dd" placeholder="结束日期" />
							</div>

						</div>
						
						<div class="search_elm">
							<button class="btn btn-small btn_search" type="submit" title="搜索" onclick="searchCount();">
								搜索
							</button>
						</div>
					</div>
				</div>
			</div>
		</div>
	</div>
	<div style="display: block;" class="widget-body " id="total">
		
	</div>
	</form>
	
	
	<div class="row">
		<div class="col-xs-12">
			<table id="grid-table"></table>
			<div id="grid-pager"></div>
			
			<div style="margin-top: 10px">
				 <span id="paging_bar" style="float: right"> </span>
			</div>
			
			<div style="margin-top: 10px">
				 <span id="paging_bar" style="float: right"> </span>
			</div>
			<span id="auth_btn">
				<a  class="btn btn-small btn-info"
					onclick="reportPrdOrdList();">导出数据文件
				</a>
				</span>
			<!-- PAGE CONTENT ENDS -->
		</div>
		<!-- /.col -->
	</div>
	<!-- /.row -->

	<!-- page specific plugin scripts -->
	<script type="text/javascript">
	var jqGrid;
	jQuery(function($) {
		var grid_selector = "#grid-table";
		var pager_selector = "#grid-pager";

		$(window).on(
				'resize.jqGrid',
				function() {
					$(grid_selector).jqGrid('setGridWidth',$(".page-content").width());
				})
		var parent_column = $(grid_selector).closest('[class*="col-"]');
		$(document).on(
				'settings.ace.jqGrid',
				function(ev, event_name, collapsed) {
					if (event_name === 'sidebar_collapsed'|| event_name === 'main_container_fixed') {
						setTimeout(function() {
							$(grid_selector).jqGrid('setGridWidth',parent_column.width());
						}, 0);
					}
				})
		jQuery(grid_selector).jqGrid({
			url : "mpomng/prdInf/rechargePrdList.do",
			datatype : "json",
			height : '100%',
			width : '100%',
			colNames : [ '订单号','商户编号  ','商户名称','订单时间','订单状态','合作商编号','合作商名称','支付方式','终端号','订单金额','费率类型','费率','手续费','到账金额','支付渠道','银行账号','银行名称','卡片名称','支付完成时间','操作' ],
			colModel : [   {name : 'prdOrdNo',        index : 'prdOrdNo',        width : '140px',sortable:false,formatter:createDetailsBtn }, 
						     {name : 'custId',        index : 'custId',        width : '120px',sortable:false }, 
						     {name : 'custName',        index : 'custName',        width : '80px',sortable:false },
						     {name : 'ordTime',        index : 'ordTime',        width : '140px',sortable:false,formatter : gridFormatByDate },
						     {name : 'ordStatus',        index : 'ordStatus',        width : '100px',sortable:false ,ditcKey:'ORDSTATUS' ,formatter : gridFormatByDict }, 
						     {name : 'agentId',        index : 'agentId',        width : '100px',sortable:false }, 
						     {name : 'agentName',        index : 'agentName',        width : '100px',sortable:false }, 
						     {name : 'payType',        index : 'payType',        width : '100px',sortable:false ,ditcKey:'PAYTYPE', formatter:gridFormatByDict}, 
						     {name : 'terNo',        index : 'terNo',        width : '100px',sortable:false }, 
						     {name : 'ordAmt',        index : 'ordAmt',        width : '100px',sortable:false }, 
						     {name : 'rateType',        index : 'rateType',        width : '100px',hidden : true,sortable:false ,ditcKey:'RATE'}, 
						     {name : 'rate',        index : 'rate',        width : '100px',hidden : true,sortable:false ,ditcKey:'RATE' }, 
						     {name : 'fee',        index : 'fee',        width : '80px',sortable:false } ,
						     {name : 'netrecAmt',        index : 'netrecamt',        width : '100px',sortable:false } ,
						     {name : 'payChannel',        index : 'payChannel',        width : '100px',sortable:false } ,
						     {name : 'payCardNo',        index : 'bankpayacno',        width : '100px',sortable:false } ,
						     {name : 'issNam',        index : 'issNam',        width : '100px',sortable:false } ,
						     {name : 'crdNam',        index : 'crdNam',        width : '100px',sortable:false } ,
						     {name : 'payOrdTime',        index : 'payOrdTime',        width : '140px',sortable:false,formatter : gridFormatByDate} ,
						     {name : '',        index : '',        width : '50px',sortable:false,formatter:operateEdit} 
			            ],
			viewrecords : true,
			rowNum : 10,
			rowList : [ 10, 20, 30 ],
			altRows : true,

			shrinkToFit : false,
			multiselect : false,//设置行可多选的 
			multiboxonly : true,//

			loadComplete : function() {
				var table = this;
				setTimeout(function() {
					//加载分页
					initPagingBar(grid_selector);
				}, 0);
			},
			beforeRequest : function() {//请求之前执行
				jqGrid = this;
			},
		});
		$(window).triggerHandler('resize.jqGrid');

		$(document).one('ajaxloadstart.page', function(e) {
			$(grid_selector).jqGrid('GridUnload');
			$('.ui-jqdialog').remove();
		});
	
		
		
	 	function operateEdit(cellvalue, options, rowObject){//定义button按钮
			var button = "<div class=\"hidden-sm hidden-xs btn-group\">";  
				button += "<button class='btn btn-xs btn-warning' onclick='rechargeDetails(\""+rowObject["prdOrdNo"]+"\")'"   
				 +"title='详细信息查看'>详细</button>";
			return button;
		};
	});
	
	
	function createDetailsBtn (cellvalue, options, rowObject){
		var button = "";  
		button += "<a class='pointer' onclick='rechargeDetails(\""+rowObject["prdOrdNo"]+"\")'"   
		 +"title='"+cellvalue+"'>"+cellvalue+"</a>";
		return button;
	}
	
	function rechargeDetails(prdOrdNo) {
		 if(prdOrdNo.length<=0){
			msg.alert("警告", "当前没有选择数据项！", "error");
			return;
		}
		var scrWidth = document.body.scrollWidth;
		openDialog({
			dialogId : 'dlg-agentEdit',
			title : '收款订单详情',
			pageUrl :'mpomng/prdInf/rechargeDetailsView.do',
			dataUrl : 'mpomng/prdInf/rechargeDetails.do',
			width : '80%',
		    height:'80%',
			dataParam : {
				prdOrdNo : prdOrdNo
			},
			dataName : 'obj,map'//表单数据存储对象名称

		}); 
		
	}
	
	
	  $(document).ready(function(){
		 searchCount();
	
	 });
	
	function searchCount(){
		 $(document).ready(function(){
			 $.ajax({
					type : "post",
					url : "mpomng/prdInf/rechargeCount.do",
					data:$("#rechargeSearchForm").serialize(),
					dataType : 'json',
					async:true,
					success : function(result) {
						if (result.rspcod != 200) {
							msg.alert("错误", result.rspmsg + " 错误代码："+ result.rspcod, 'error');
						} else {
							var count=result.obj.cntNum;
							var txamt=result.obj.cntOrdAmt;
							var fee=result.obj.cntFee;
							if(!count){
								count="0";
							}
							if(!txamt){
								txamt="0";
							}
							if(!fee){
								fee="0";
							}
							var html="";
							html+="汇总笔数和金额:["+count+"]笔  |  [" +txamt+ "]元  "
							html+="&nbsp;&nbsp;&nbsp;&nbsp;";
							html+="手续费总额:["+fee+"]元";
							$("#total").html(html);
							
						}
					},
					error : function(XMLHttpRequest, textStatus) {
						msg.alert("错误", "错误代码：" + XMLHttpRequest.status + ",错误描述："+ textStatus, 'error');
					}
				});
		

	});
		
	}
	
	/**
	*导出交易订单
	*/
	function reportPrdOrdList(){
		var querycon = getFormParams($("#rechargeSearchForm"));
		msg.confirm({title:'确认',position:'center',msg:'为了能够正常导出,请控制查询条件以控制导出数据量!您确定要导出当前数据吗?',call:function(ok){
			if(ok){
				$.ajax({
					type : "post",
					url : 'mpomng/prdInf/report.do',
					dataType : 'json',
					data:querycon,
					success : function(result) {
						if (result.rspcod != 200) {
							msg.alert("错误", result.rspmsg + " 错误代码："+ result.rspcod, 'error');
						} else {
							msg.alert("提示", result.rspmsg, 'correct');
							$("#grid-table").trigger("reloadGrid");
						}
					},
					error : function(XMLHttpRequest, textStatus) {
						msg.alert("错误", "错误代码：" + XMLHttpRequest.status + ",错误描述："+ textStatus, 'error');
					}
				});
			}
		}});
	}
	
	
	
	
	</script>